package acm.蓝桥4;

import java.util.Scanner;

public class 水滴高度 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long res=n;
        for (int i = 3; i <= n; i+=2) {
            res=Math.max(res,fun(i));
        }
        System.out.println(res);
    }

    public static long fun(long n) {
        long res = n;
        while (n != 1) {
            n = n * 3 + 1;
            res=Math.max(res,n);
            while (n % 2 == 0) {
                n = n >> 1;
            }
        }
        return res;
    }
}
